<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of admin_utilizador
 *
 * @author Leonardo Lino
 */
class Utilizador extends CI_Controller {
    private $smarty;

    public function __construct() {
        parent::__construct();
        $this->load->library('session');
        $session_id = $this->session->userdata('session_id');
        require_once 'smartyLoader.php';
        $this->smarty = $smarty;
        $this->user->isAccessBackOffice($this->smarty);
    }

    public function index() {

        $users = $this->user->listUsers();

        ($users == null) ? $vazio = 0 : $vazio = 1;

        $this->smarty->assign("vazio", $vazio);
        $this->smarty->assign("users", $users);
        $this->smarty->assign("templateActivo", "utilizador.tpl.html");


        $this->smarty->display('admin/header.tpl.html');
        $this->smarty->display('admin/main.tpl.html');
        $this->smarty->display('admin/footer.tpl.html');
    }

    public function novo() {

        $users = $this->user->createUser($_POST['utilizador'], $_POST['password'], $_POST['tipo']);

        $this->index();
    }

}

?>
